package com.briup.recognition.service.impl;

import com.briup.recognition.bean.BaseFile;
import com.briup.recognition.bean.BaseFileExample;
import com.briup.recognition.dao.BaseFileMapper;
import com.briup.recognition.service.BaseFileService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @Author: xiaoxiao
 * @Description: 工具
 * @DateTime: 2021/3/28$ 17:13$
 * @Params: $
 * @Return $
 */
@Service
public class BaseFileServiceImpl implements BaseFileService {

    @Resource
    private BaseFileMapper baseFileMapper;

    @Override
    public List<BaseFile> query(){
        BaseFileExample example = new BaseFileExample();
        return baseFileMapper.selectByExample(example);
    }

    @Override
    public void saveOrUpdate(BaseFile baseFile) {
        if (baseFile.getId()!=null){
            baseFileMapper.updateByPrimaryKey(baseFile);
        } else {
            //初始化
            /*baseFile.setStatus("正常");*/
            baseFile.setUploadTime(new Date().getTime());


            baseFileMapper.insert(baseFile);
        }
    }

    @Override
    public void deleteById(long id) {
        baseFileMapper.deleteByPrimaryKey(id);
    }
}
